package com.whnk.model.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.whnk.common.log.annotation.Log;
import com.whnk.common.log.enums.BusinessType;
import com.whnk.common.security.annotation.PreAuthorize;
import com.whnk.model.domain.DefTTaskOpLogDetail;
import com.whnk.model.service.IDefTTaskOpLogDetailService;
import com.whnk.common.core.web.controller.BaseController;
import com.whnk.common.core.web.domain.AjaxResult;
import com.whnk.common.core.utils.poi.ExcelUtil;
import com.whnk.common.core.web.page.TableDataInfo;

/**
 * 任务明细记录表Controller
 *
 * @author whnk
 * @date 2021-10-20
 */
@RestController
@RequestMapping("/taskOpLogDetail")
public class DefTTaskOpLogDetailController extends BaseController
{
    @Autowired
    private IDefTTaskOpLogDetailService defTTaskOpLogDetailService;

    /**
     * 查询任务明细记录表列表
     */
    @PreAuthorize(hasPermi = "model:detail:list")
    @GetMapping("/list")
    public TableDataInfo list(DefTTaskOpLogDetail defTTaskOpLogDetail)
    {
        startPage();
        List<DefTTaskOpLogDetail> list = defTTaskOpLogDetailService.selectDefTTaskOpLogDetailList(defTTaskOpLogDetail);
        return getDataTable(list);
    }

    /**
     * 导出任务明细记录表列表
     */
    @PreAuthorize(hasPermi = "model:detail:export")
    @Log(title = "导出任务明细记录表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DefTTaskOpLogDetail defTTaskOpLogDetail) throws IOException
    {
        List<DefTTaskOpLogDetail> list = defTTaskOpLogDetailService.selectDefTTaskOpLogDetailList(defTTaskOpLogDetail);
        ExcelUtil<DefTTaskOpLogDetail> util = new ExcelUtil<DefTTaskOpLogDetail>(DefTTaskOpLogDetail.class);
        util.exportExcel(response, list, "导出任务明细记录表数据");
    }

    /**
     * 获取任务明细记录表详细信息
     */
    @PreAuthorize(hasPermi = "model:detail:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(defTTaskOpLogDetailService.selectDefTTaskOpLogDetailById(id));
    }

    /**
     * 新增任务明细记录表
     */
    @PreAuthorize(hasPermi = "model:detail:add")
    @Log(title = "新增任务明细记录表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DefTTaskOpLogDetail defTTaskOpLogDetail)
    {
        return toAjax(defTTaskOpLogDetailService.insertDefTTaskOpLogDetail(defTTaskOpLogDetail));
    }

    /**
     * 修改任务明细记录表
     */
    @PreAuthorize(hasPermi = "model:detail:edit")
    @Log(title = "修改任务明细记录表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DefTTaskOpLogDetail defTTaskOpLogDetail)
    {
        return toAjax(defTTaskOpLogDetailService.updateDefTTaskOpLogDetail(defTTaskOpLogDetail));
    }

    /**
     * 删除任务明细记录表
     */
    @PreAuthorize(hasPermi = "model:detail:remove")
    @Log(title = "删除任务明细记录表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(defTTaskOpLogDetailService.deleteDefTTaskOpLogDetailByIds(ids));
    }
}
